using UnityEngine;
using System.Collections;

public class Menu2 : MonoBehaviour {

public GameObject prefabArrow;
	
	private GameObject cursor;
	
	private int cursorPos = 1;
	
	private int delay = 0;
	
	// Use this for initialization
	void Start () {
		cursor = (GameObject) Instantiate(prefabArrow,new Vector3(-4.5f, 1.3f, 0), Quaternion.identity);
		cursor.transform.Rotate (0f,0f,270f);
	}
	
	// Update is called once per frame
	void Update () {
	/*
	 * Y do cursor: -1.8,  -3.2, -4.6 
	 * 
	*/
		
		if(Input.GetKeyDown(KeyCode.KeypadEnter) || Input.GetKeyDown(KeyCode.Space) ){
			if(cursorPos == 1){
				Application.LoadLevel("Game1");
			}
			else if (cursorPos == 2){
				Application.LoadLevel("Game2");
			}
		
		}
		
		if(delay > 24){			
			//moving cursor
			if(Input.GetKey(KeyCode.UpArrow)){
				delay = 0;
				//print(player.transform.position.y);
				if(cursorPos > 1){
					cursorPos --;
					cursor.transform.Translate ( -3.6f, 0, 0);
				}else{
					//move to last possible position
					cursorPos = 2; //last position number
					cursor.transform.position = new Vector3 (-4.5f, -2.3f, 0); //last position vector
				}
			}
			else if(Input.GetKey(KeyCode.DownArrow)){
				delay = 0;
				//print(player.transform.position.y);
				if(cursorPos < 2){ //last position number
					cursorPos ++;
					cursor.transform.Translate ( 3.6f, 0, 0);
				}else{
					//move to first possible position
					cursorPos = 1; //first position number
					cursor.transform.position = new Vector3 (-4.5f, 1.3f, 0); //first position vector
				}
			}
			
			
		}else{
			delay ++;
		} 
	 
	}
}
